<%@ page language="java" import="java.util.*,entity.*,dao.*,dao.impl.*" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
TopicDao topicDao = new TopicDaoImpl();
ReplyDao replyDao = new ReplyDaoImpl();
UserDao userDao = new UserDaoImpl();
BoardDao boardDao = new BoardDaoImpl();

int boardId = Integer.parseInt(request.getParameter("boardId")); // 取得板块id
int p = Integer.parseInt(request.getParameter("page")); // 取得页数
List listTopic = topicDao.findListTopic(p,boardId); // 取得该板块主题列表
Board board = boardDao.findBoard(boardId); // 取得板块信息

int prep = p; // 上一页
int nextp = p; // 下一页
if(listTopic.size()==20) {
	nextp = p+1;
}
if( p>1 ){
	prep = p-1;
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/xhtml/DTD/xhtml1-transitional.dtd">
<htmlxmlns = "http://www.w3.org/1999/xhtml">
  <head>
  	<meta http-equiv="Content-Type" content="text/html; charset = utf-8"/>
    <title>欢迎来到-帖子列表</title>
	
	<link rel="stylesheet" type="text/css" href="styles.css">
	
  </head>
  
  <body>
    	<div id="apDiv1">
			<div align ="center" class="STYLE1 textColor navbar-brand">
				<span class="font-weight-bold align-middle ml-3 d-inline-block">校</span>
				<span class="font-weight-bold align-middle ml-3 d-inline-block">园</span>
				<span class="font-weight-bold align-middle ml-3 d-inline-block">B</span>
				<span class="font-weight-bold align-middle ml-3 d-inline-block">B</span>
				<span class="font-weight-bold align-middle ml-3 d-inline-block">S</span>
				<span class="font-weight-bold align-middle ml-3 d-inline-block">系</span>
				<span class="font-weight-bold align-middle ml-3 d-inline-block">统</span>
			  </div>
		</div>
		<%
			if(session.getAttribute("user")==null){
		%>
		<div class="STYLE4" id="apDiv2">
			您尚未<a href="login.jsp" target="_blank">登录</a>
			|
			<a href="reg.jsp" target="_blank" style="color:#fe7300;">注册</a>
		</div>
		<%
			}else{
				User loginUser=(User)session.getAttribute("user");
		%>
		<div class="STYLE4">
			您好:<%=loginUser.getUserName() %>
			&nbsp;&nbsp;&nbsp;&nbsp;<a href="manage/doLogout.jsp">退出</a>
		</div>
		<%
		}
		%>
		<!-- 主体 -->
		<div>
			<!-- 导航 -->
			<br/>
			<div>
				&gt;&gt;<b><a href="index.jsp">论坛首页</a></b>&gt;&gt;
				<b><a href="list.jsp?page=1&boardId=<%=boardId %>"><%=board.getBoardName() %></a></b>
			</div>
			<br/>
			<!-- 新帖 -->
			<div>
				<a href="post.jsp?boardId=<%=boardId %>"><input type="submit" name="button" id="button" value="发帖"/></a>
			</div>
			<!-- 翻页 -->
			<div>
				<a href="list.jsp?page=<%=prep%>&boardId=<%=boardId %>">上一页</a>
				|
				<a href="list.jsp?page=<%=nextp%>&boardId=<%=boardId %>">下一页</a>
			</div>
			<div class="t">
				
				<table width="100%" height="503" border="1" cellpadding="0" cellspacing="0">
					<tr>
						
					</tr>
					<!-- 表头 -->
					<tr class="tr2">
						<td>&nbsp;</td>
						<td style="WIDTH:80%" align="center" class="transitional">文章</td>
						<td style="WIDTH:10%" align="center" class="transitional">作者</td>
						<td style="WIDTH:10%" align="center" class="transitional">回复</td>
					</tr>
					<!-- 主题列表 -->
					<%
						for(int i=0;i<listTopic.size();i++){
						Topic topic = (Topic)listTopic.get(i);
						User user = userDao.findUser(topic.getUserId());
					%>
					<tr class="tr3">
						<td>
							<img src="image/topic.gif" border="0">
						</td>
						<td style="FONT-SIZE:15px">
							<a href="detail.jsp?page=1&boardId=<%=boardId %>&topicId=<%=topic.getTopicId() %>">
								<%=topic.getTitle()%>
							</a>
						</td>
						<td align="center">
							<%=user.getUserName()%>
						</td>
						<td align="center">
							<%=replyDao.findCountReply(topic.getTopicId())%>
						</td>
					</tr>
					<%
				}
					%>
				</table>
			</div>
			<div>
				<a href="list.jsp?page=<%=prep%>&boardId=<%=boardId %>">上一页</a>
				|
				<a href="list.jsp?page=<%=nextp%>&boardId=<%=boardId %>">下一页</a>
			</div>
		</div>
  </body>
</html>
